<template>
    <div>
        <address-item v-for="item in address" :key="item.id"
            :name="item.name"
            :phone="item.phone"
            :city="item.city"
            :detail="item.detail"
            :id="item.id"
        ></address-item>
        <router-link to="/addAddress">新增地址</router-link>
    </div>
</template>

<script>
import {mapActions,mapState} from 'vuex';
import addressItem from '@/components/address-item.vue';
export default {
    data(){
        return {

        }
    },
    components:{
        addressItem
    },
    computed:{
        ...mapState(['address'])
    },
    created(){
        //获取地址
        if(!this.address.length){
            this.getAddress();
        }
    },
    methods:{
        ...mapActions(['getAddress'])
    }
}
</script>